﻿// Copyright © Microsoft Corporation.  All Rights Reserved.
// This code released under the terms of the 
// Microsoft Public License (MS-PL, http://opensource.org/licenses/ms-pl.html.)

using System.Windows;
using System.Windows.Interactivity;

namespace TheOliver.Controls
{
    public class ChangeVisibilityBehavior : TargetedTriggerAction<UIElement>
    {
        protected override void Invoke(object parameter)
        {
            RoutedEventArgs args = parameter as RoutedEventArgs;

            if (args != null)
            {
                if (Target.Visibility == Visibility.Visible)
                {
                    Target.Visibility = Visibility.Collapsed;
                }
                else
                {
                    Target.Visibility = Visibility.Visible;
                }
            }
        }
    }
}
